﻿using System.Net;
using System.Net.Http;

namespace Neo4jConnect.Rest
{
    public class HttpClientExtensionService : IExtensionService
    {
        private readonly HttpClient client;

        public HttpClientExtensionService(HttpClient client)
        {
            this.client = client;
        }

        public string GetExtensions()
        {
            return client
                .Get("ext")
                .EnsureStatusCode(HttpStatusCode.OK)
                .Content.ReadAsString();            
        }

        public string GetExtensionInfo(string extensionName)
        {
            return client
                .Get(string.Format("ext/{0}", extensionName))
                .EnsureStatusCode(HttpStatusCode.OK)
                .Content.ReadAsString();
        }
    }
}
